From 11ad0f9d65d513ca46cc611566c21aeadc669d69 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Mon, 9 Feb 2004 20:31:38 +0000 Subject: [PATCH] Fix #132256. 2004-02-09 Federico Mena Quintero Fix #132256. * gtk/gtkfilechooserdefault.c (gtk_file_chooser_default_get_paths): Read the contents of the filename entry in both OPEN and SAVE mode. In multiple-selection mode, add this to the selection from the file/folder list. (struct get_paths_closure): Add a path_from_entry field. (get_paths_foreach): Only add the iterated path if it is not the same as the path from the entry. --- ChangeLog | 12 ++++++ ChangeLog.pre-2-10 | 12 ++++++ ChangeLog.pre-2-4 | 12 ++++++ ChangeLog.pre-2-6 | 12 ++++++ ChangeLog.pre-2-8 | 12 ++++++ gtk/gtkfilechooserdefault.c | 76 +++++++++++++++++++++---------------- 6 files changed, 104 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index a0133ef50d..9af0293437 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-02-09 Federico Mena Quintero + + Fix #132256. + + * gtk/gtkfilechooserdefault.c + (gtk_file_chooser_default_get_paths): Read the contents of the + filename entry in both OPEN and SAVE mode. In multiple-selection + mode, add this to the selection from the file/folder list. + (struct get_paths_closure): Add a path_from_entry field. + (get_paths_foreach): Only add the iterated path if it is not the + same as the path from the entry. + 2004-02-09 Federico Mena Quintero * gtk/gtkfilesystemunix.c (gtk_file_system_unix_get_folder): If diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index a0133ef50d..9af0293437 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,15 @@ +2004-02-09 Federico Mena Quintero + + Fix #132256. + + * gtk/gtkfilechooserdefault.c + (gtk_file_chooser_default_get_paths): Read the contents of the + filename entry in both OPEN and SAVE mode. In multiple-selection + mode, add this to the selection from the file/folder list. + (struct get_paths_closure): Add a path_from_entry field. + (get_paths_foreach): Only add the iterated path if it is not the + same as the path from the entry. + 2004-02-09 Federico Mena Quintero * gtk/gtkfilesystemunix.c (gtk_file_system_unix_get_folder): If diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index a0133ef50d..9af0293437 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,15 @@ +2004-02-09 Federico Mena Quintero + + Fix #132256. + + * gtk/gtkfilechooserdefault.c + (gtk_file_chooser_default_get_paths): Read the contents of the + filename entry in both OPEN and SAVE mode. In multiple-selection + mode, add this to the selection from the file/folder list. + (struct get_paths_closure): Add a path_from_entry field. + (get_paths_foreach): Only add the iterated path if it is not the + same as the path from the entry. + 2004-02-09 Federico Mena Quintero * gtk/gtkfilesystemunix.c (gtk_file_system_unix_get_folder): If diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index a0133ef50d..9af0293437 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,15 @@ +2004-02-09 Federico Mena Quintero + + Fix #132256. + + * gtk/gtkfilechooserdefault.c + (gtk_file_chooser_default_get_paths): Read the contents of the + filename entry in both OPEN and SAVE mode. In multiple-selection + mode, add this to the selection from the file/folder list. + (struct get_paths_closure): Add a path_from_entry field. + (get_paths_foreach): Only add the iterated path if it is not the + same as the path from the entry. + 2004-02-09 Federico Mena Quintero * gtk/gtkfilesystemunix.c (gtk_file_system_unix_get_folder): If diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index a0133ef50d..9af0293437 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,15 @@ +2004-02-09 Federico Mena Quintero + + Fix #132256. + + * gtk/gtkfilechooserdefault.c + (gtk_file_chooser_default_get_paths): Read the contents of the + filename entry in both OPEN and SAVE mode. In multiple-selection + mode, add this to the selection from the file/folder list. + (struct get_paths_closure): Add a path_from_entry field. + (get_paths_foreach): Only add the iterated path if it is not the + same as the path from the entry. + 2004-02-09 Federico Mena Quintero * gtk/gtkfilesystemunix.c (gtk_file_system_unix_get_folder): If diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index c6b1b565c4..487e15b35b 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -2275,8 +2275,9 @@ gtk_file_chooser_default_unselect_all (GtkFileChooser *chooser) } struct get_paths_closure { - GSList *result; GtkFileChooserDefault *impl; + GSList *result; + GtkFilePath *path_from_entry; }; static void @@ -2304,58 +2305,69 @@ get_paths_foreach (GtkTreeModel *model, } file_path = _gtk_file_system_model_get_path (fs_model, &sel_iter); - info->result = g_slist_prepend (info->result, gtk_file_path_copy (file_path)); + + if (!info->path_from_entry + || gtk_file_path_compare (info->path_from_entry, file_path) != 0) + info->result = g_slist_prepend (info->result, gtk_file_path_copy (file_path)); } static GSList * gtk_file_chooser_default_get_paths (GtkFileChooser *chooser) { GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser); - GtkTreeSelection *selection; + GtkFileChooserEntry *chooser_entry; + const GtkFilePath *folder_path; + const gchar *file_part; struct get_paths_closure info; - if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE) - { - GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (impl->entry); - const GtkFilePath *folder_path = _gtk_file_chooser_entry_get_current_folder (chooser_entry); - const gchar *file_part = _gtk_file_chooser_entry_get_file_part (chooser_entry); + info.impl = impl; + info.result = NULL; + info.path_from_entry = NULL; - if (file_part != NULL && file_part[0] != '\0') - { - GtkFilePath *selected; - GError *error = NULL; + chooser_entry = GTK_FILE_CHOOSER_ENTRY (impl->entry); + folder_path = _gtk_file_chooser_entry_get_current_folder (chooser_entry); + file_part = _gtk_file_chooser_entry_get_file_part (chooser_entry); - selected = gtk_file_system_make_path (impl->file_system, folder_path, file_part, &error); + if (file_part != NULL && file_part[0] != '\0') + { + GtkFilePath *selected; + GError *error = NULL; - if (!selected) - { - error_building_filename_dialog (impl, folder_path, file_part, error); - return NULL; - } + selected = gtk_file_system_make_path (impl->file_system, folder_path, file_part, &error); - return g_slist_append (NULL, selected); + if (!selected) + { + error_building_filename_dialog (impl, folder_path, file_part, error); + return NULL; } + + info.path_from_entry = selected; } - if (impl->folder_mode) + if (!info.path_from_entry || impl->select_multiple) { - if (!impl->tree_model) - return NULL; + GtkTreeSelection *selection; - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->tree)); - } - else - { - if (!impl->sort_model) - return NULL; + selection = NULL; - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->list)); + if (impl->folder_mode) + { + if (impl->tree_model) + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->tree)); + } + else + { + if (impl->sort_model) + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->list)); + } + + if (selection) + gtk_tree_selection_selected_foreach (selection, get_paths_foreach, &info); } - info.result = NULL; - info.impl = impl; + if (info.path_from_entry) + info.result = g_slist_prepend (info.result, info.path_from_entry); - gtk_tree_selection_selected_foreach (selection, get_paths_foreach, &info); return g_slist_reverse (info.result); } -- 2.30.2